<template>
  <div id="main"></div>
</template>

<script>
import E from "wangeditor";

export default {
  data() {
    return {
      editor: {},
    };
  },
  mounted() {
    this.editor = new E("#main");
    // 或者 const editor = new E( document.getElementById('div1') )
    // 配置菜单栏，删减菜单，调整顺序
    this.editor.config.menus = ["bold", "head", "link", "italic", "underline"];
    // 配置 onchange 回调函数
    this.editor.config.onchange = (newHtml) => {
      //   将获取的文本内容发送给父组件
      this.$emit("sendTxt", newHtml);
    };
    // 取消自动 focus
    this.editor.config.focus = false;
    // 配置触发 onchange 的时间频率，默认为 200ms
    this.editor.config.onchangeTimeout = 500;
    this.editor.create();
  },
};
</script>

<style>
</style>